﻿namespace Monadic.Tests
{
    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    [TestClass]
    public class MonadTests
    {
        [TestMethod]
        public void BasicMonad()
        {
            var monad = new Monad<int>(1);
            var monad2 = monad.Bind(v => new Monad<int>(v));
            Assert.AreEqual(monad, monad2);
            Assert.AreNotSame(monad, monad2);
        }

        [TestMethod]
        public void BasicMonadWithFactory()
        {
            var monad = Monad.Create(1);
            var monad2 = monad.Bind(v => Monad.Create(v));
            Assert.AreEqual(monad, monad2);
            Assert.AreNotSame(monad, monad2);
        }

        [TestMethod]
        public void ProjectionShouldReturnProjectedMonad()
        {
            var monad = Monad.Create(1).Select(n => n + 1);
            Assert.AreEqual(Monad.Create(2), monad);
            Assert.AreNotEqual(Monad.Create(3), monad);         
        }
    }
}
